package com.yupi.springbootinit.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yupi.springbootinit.common.BaseResponse;
import com.yupi.springbootinit.common.DeleteRequest;
import com.yupi.springbootinit.common.ResultUtils;
import com.yupi.springbootinit.model.dto.qa.QaInspectionReportDimAddRequest;
import com.yupi.springbootinit.model.dto.qa.QaInspectionReportDimQueryRequest;
import com.yupi.springbootinit.model.dto.qa.QaInspectionReportDimUpdateRequest;
import com.yupi.springbootinit.model.entity.QaInspectionReportDim;
import com.yupi.springbootinit.service.QaInspectionReportDimService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import jakarta.annotation.Resource;
import java.util.List;

/**
 * 检验报告尺寸接口
 *
 * @author zhang
 * @date 2024/02/25
 */
@RestController
@RequestMapping("/qa/inspection-report-dim")
@Slf4j
public class QaInspectionReportDimController {

    @Resource
    private QaInspectionReportDimService qaInspectionReportDimService;

    // region 增删改查

    /**
     * 创建
     *
     * @param qaInspectionReportDimAddRequest
     * @return
     */
    @PostMapping("/add")
    public BaseResponse<Long> addQaInspectionReportDim(@RequestBody QaInspectionReportDimAddRequest qaInspectionReportDimAddRequest) {
        long result = qaInspectionReportDimService.addQaInspectionReportDim(qaInspectionReportDimAddRequest);
        return ResultUtils.success(result);
    }

    /**
     * 删除
     *
     * @param deleteRequest
     * @return
     */
    @PostMapping("/delete")
    public BaseResponse<Boolean> deleteQaInspectionReportDim(@RequestBody DeleteRequest deleteRequest) {
        boolean result = qaInspectionReportDimService.deleteQaInspectionReportDim(deleteRequest);
        return ResultUtils.success(result);
    }

    /**
     * 更新
     *
     * @param qaInspectionReportDimUpdateRequest
     * @return
     */
    @PostMapping("/update")
    public BaseResponse<Boolean> updateQaInspectionReportDim(@RequestBody QaInspectionReportDimUpdateRequest qaInspectionReportDimUpdateRequest) {
        boolean result = qaInspectionReportDimService.updateQaInspectionReportDim(qaInspectionReportDimUpdateRequest);
        return ResultUtils.success(result);
    }

    /**
     * 根据 id 获取
     *
     * @param id
     * @return
     */
    @GetMapping("/get")
    public BaseResponse<QaInspectionReportDim> getQaInspectionReportDimById(long id) {
        QaInspectionReportDim qaInspectionReportDim = qaInspectionReportDimService.getQaInspectionReportDimById(id);
        return ResultUtils.success(qaInspectionReportDim);
    }

    /**
     * 获取列表
     *
     * @param qaInspectionReportDimQueryRequest
     * @return
     */
    @GetMapping("/list")
    public BaseResponse<List<QaInspectionReportDim>> listQaInspectionReportDim(QaInspectionReportDimQueryRequest qaInspectionReportDimQueryRequest) {
        List<QaInspectionReportDim> list = qaInspectionReportDimService.listQaInspectionReportDim(qaInspectionReportDimQueryRequest);
        return ResultUtils.success(list);
    }

    /**
     * 分页获取列表
     *
     * @param qaInspectionReportDimQueryRequest
     * @return
     */
    @GetMapping("/list/page")
    public BaseResponse<Page<QaInspectionReportDim>> listQaInspectionReportDimByPage(QaInspectionReportDimQueryRequest qaInspectionReportDimQueryRequest) {
        Page<QaInspectionReportDim> page = qaInspectionReportDimService.listQaInspectionReportDimByPage(qaInspectionReportDimQueryRequest);
        return ResultUtils.success(page);
    }

    // endregion
}